Earlier today I did a code maintenance session on BlogEngine.NET using the excellent FxCop tool. It was a while since I’ve did so there were quite a few things to correct in the code. I actually like spending time with FxCop and fixing the broken rules. There’s something very relaxing about it. Even though FxCop is excellent, it is not without its quirks.

Compound words should be cased correctly

Based on this rule, FxCop told me to correct the spelling of Whitespace to WhiteSpace. I didn’t think more about it and just accepted that whitespace probably isn’t one word but two. After the change I ran FxCop again and, lo and behold, it suggested that I should change WhiteSpace back to Whitespace. Hmm, thought I just did the opposite because it broke the rule.

Avoid namespaces with few types

This rule makes sense if you only have a single class in a namespace, but it breaks if you have fewer than 5 types. Now here is the thing. I have a namespace with only four types and I want it that way. Stop telling me that I shouldn’t!

Do not pass literals as localized parameters

This rule is a globalization rule that breaks if you write the content of a string manually in the source files instead of putting them in resource files. When I throw some exceptions or construct some strings that I know will not be localized then I couldn’t care less about this rule. If I were to put every string in a resource file, it would be hard to work with. I turned the rule off.

Do not declare static members on generic types

In English: Don’t write a static method or property that uses Generics in its declaration. The rule also states that you must never exclude that rule no matter what. It states that in order to call that method you need to write bad code such as

someObject.GenericMethod<int>();

Well, that is not correct. You can have a static member using Generics without calling it with the <type> syntax if you know how to write the members correctly. Apparently it doesn’t take smart people into account for this one.

Conclusion

Even though this post sounds a bit negative I’m still a big fan of FxCop. Some of these rules are perfectly fine to break according for some scenarios. The rules state that them selves. These few ones have just annoyed me ever since I started using FxCop a couple of years ago.

Every now and then I need some modules, components or code snippets for my various projects only to find out on Google that they don’t exist. No one have invented/published/written them and that’s a shame. Here is a list of some of the things I’d like to have someone (other than myself) write and publish as open source:

1. Silverlight XHTML editor

All the JavaScript based editors such as TinyMCE, FCKeditor and FreeTextBox are all pretty nice, but they are still not quite there. With Silverlight we can now make something truly spectacular. Think of adding images to a blog post and harvest all the imaging power of the System.Drawing namespace right there. It would be able to build something better, faster, nicer (XAML for God sake!) and totally integrated into your ASP.NET application.

2. OpenID membership provider for ASP.NET

OpenID is a promising authentication technology that I would like to play with in various projects including BlogEngine.NET. There are already some ASP.NET controls and libraries out there, but no membership provider. I don’t want to use a library and then have to write the membership provider on top of that. I want a single C# file that I can just register in the web.config and voila!

It doesn’t matter if it uses SQL or XML because that can fairly easily be converted and I need both.

3. ASP.NET MonsterID implementation

A MonsterID is an auto generated image that is based on an e-mail address. The same e-mail always produces the same monster. The image of a monster is based on various different pieces such as body, 2 eyes, hair, arms and legs. These images come in multiple varieties and is put together based on the e-mail address and an algorithm. The monster parts can be from the Combinatoric.Critters website or from the MonsterID download for PHP. The idea is that it should be used instead of Identicons and use the e-mail instead of the IP address.

What I need is a single HttpHandler that renders the image and serves it based on a hashed e-mail address provided from the query string. It must save the rendered image on disk, so it doesn’t have to recreate it every time it loads.

So if you are bored this summer, why not create something that doesn’t exist and claim the fame?